# for的四种方式
for i in range(1, 10):
    for k in range(i + 1, 10):
        # 补充空格达到右对齐的效果
        print(end="          ")
    for j in range(i, 0, -1):
        print("{:<2}*{:<2}={:<4}".format(i, j, i*j), end="")
    print("")

for i in range(9, 0, -1):
    for k in range(9, i, -1):
        print(end="          ")
    for j in range(i, 0, -1):
        print("{:<2}*{:<2}={:<4}".format(i, j, i*j), end="")
    print("")

for i in range(1, 10):
    for k in range(1, i+1):
        print('{:<2}*{:<2}={:<4}'.format(i, k, i*k), end='')
    print('')

for i in range(9, 0, -1):
    for k in range(1, i+1):
        print('{:<2}*{:<2}={:<4}'.format(i, k, i*k), end='')
    print('')

# while的四种用法
i = 1
while i < 10:
    k = 1
    while k < i+1:
        print('{:<2}*{:<2}={:<4}'.format(i, k, i*k), end='')
        k += 1
    print('')
    i += 1

i = 9
while i > 0:
    k = 1
    while k < i+1:
        print('{:<2}*{:<2}={:<4}'.format(i, k, i*k), end='')
        k += 1
    print('')
    i -= 1

i = 1
while i < 10:
    k = 1
    j = i
    while k < 10 - i:
        print(end="          ")
        k += 1
    while j > 0:
        print('{:<2}*{:<2}={:<4}'.format(i, j, i * j), end='')
        j -= 1
    print('')
    i += 1

i = 9
while i > 0:
    k = 1
    j = i
    while k < 10 - i:
        print(end="          ")
        k += 1
    while j > 0:
        print('{:<2}*{:<2}={:<4}'.format(i, j, i * j), end='')
        j -= 1
    print('')
    i -= 1
